<template>
  <span>
    <el-tag :type="type" effect="dark">{{ state.labelValue }}</el-tag>
  </span>
</template>
<script setup lang="ts" name="dicItemsEtag">
import { useSysApi } from "/@/api/sys/index";
import { onMounted, reactive, defineProps } from 'vue';
const props = defineProps({ dicCode: String, microServiceName: String, language: String, dataType: String, type: String, value: String })


const refresh = () => {
  useSysApi().selectDicItemsByDicCodeToNameAndValue(props.dicCode, props.microServiceName, props.language, props.dataType).then(data => {
    state.labelValue = props.value;  // 这里进行兜底处理，如果没有匹配就显示当前的值
    for (let index = 0; index < data.length; index++) {
      if (props.value == data[index].value) {
        state.labelValue = data[index].label;
        break;
      }
    }
  });
};

let state = reactive({ labelValue: "" });

onMounted(() => {
  refresh()
});

</script>
